<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="产品物料编码" prop="itemCode">
        <el-input v-model="queryParams.itemCode" placeholder="请输入产品物料编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="产品物料名称" prop="itemName">
        <el-input v-model="queryParams.itemName" placeholder="请输入产品物料名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="仓库名称" prop="warehouseName">
        <el-input v-model="queryParams.warehouseName" placeholder="请输入仓库名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="库区名称" prop="locationName">
        <el-input v-model="queryParams.locationName" placeholder="请输入库区名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="库位名称" prop="areaName">
        <el-input v-model="queryParams.areaName" placeholder="请输入库位名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="呆滞天数" prop="areaName">
        <el-input-number v-model="queryParams.attr3" placeholder="请输入呆滞天数" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="inventoryList" height="calc(100vh - 230px)">
      <el-table-column type="index" label="序号" align="center" width="50" />
      <el-table-column label="仓库编码" width="100px" align="center" prop="warehouseCode" />
      <el-table-column label="仓库名称" width="100px" align="center" prop="warehouseName" />
      <el-table-column label="库区编码" width="100px" align="center" prop="locationCode" />
      <el-table-column label="库区名称" width="100px" align="center" prop="locationName" />
      <el-table-column label="库位编码" width="100px" align="center" prop="areaCode" />
      <el-table-column label="库位名称" width="100px" align="center" prop="areaName" />
      <el-table-column label="产品物料编码" width="100px" align="center" prop="itemCode" />
      <el-table-column label="产品物料名称" width="100px" align="center" prop="itemName" />
      <el-table-column label="规格型号" width="100px" align="center" prop="specification" />
      <el-table-column label="单位" width="100px" align="center" prop="unitOfMeasure" />
      <el-table-column label="数量" width="100px" align="center" prop="quantity" />
      <el-table-column label="最后入库时间" width="100px" align="center" prop="lastTime" />
      <el-table-column label="最大库存" width="100px" align="center" prop="max" />
      <el-table-column label="最小库存" width="100px" align="center" prop="min" />
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { listByQuantity, listByDate } from "@/api/mes/wm/inventory";
export default {
  name: "Inventory1",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      itemTypeName: null,
      // 总条数
      total: 0,
      //物料产品分类树
      itemTypeOptions: undefined,
      // 库存记录表格数据
      inventoryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        itemId: null,
        itemCode: null,
        itemName: null,
        warehouseId: null,
        warehouseCode: null,
        warehouseName: null,
        locationId: null,
        locationCode: null,
        locationName: null,
        areaId: null,
        areaCode: null,
        areaName: null,
        attr3: 180,
      },
      // 表单参数
      form: {},
    };
  },
  watch: {},
  created() {
    this.getList();
  },
  methods: {
    /** 查询库存记录列表 */
    getList() {
      this.loading = true;
      listByDate(this.queryParams).then((response) => {
        this.inventoryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.attr3 = 180;
      this.handleQuery();
    },
  },
};
</script>
